<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <img class="outline-parent-bg" :src="publicUrls + 'free/style8/Auxiliaryoutlinestyle4Bg.webp'" alt="" />
    <div class="outline border-hover-style">
      <div
        class="audio-box"
        :class="isPlay && 'audio-rotate'"
        v-if="props.info.audio && props.info.audio.url"
        @click="audioplay(true)"
      >
        <i class="doorIcon">&#xe688;</i>
      </div>
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
      <div class="outline-title">
        <p>{{ props.info.text }}</p>
        <img class="outline-title-bg" :src="publicUrls + 'free/style8/Auxiliaryoutlinestyle4BgTitle.webp'" alt="" />
      </div>

      <div
        class="content-box"
        v-if="(props.info.value || (props.info.video && props.info.video.url)) && props.info.remarks"
      >
        <div class="outline-content">
          <p class="outline-subTitle" v-if="props.info.subTitle">
            {{ props.info.subTitle }}
          </p>
          <div class="TextMax-box">
            <TextMax
              v-if="props.domShow"
              :data="props.info.remarks"
              :title="props.info.text"
              :infoData="props.info"
              :row="props.info.subTitle ? 5 : 7"
            ></TextMax>
          </div>
        </div>
        <div
          class="content-item"
          v-if="props.info.value || (props.info.video && props.info.video.url)"
          :style="!props.info.remarks && { marginLeft: '0' }"
        >
          <div class="medium">
            <img
              v-if="props.info.value && !(props.info.video && props.info.video.url)"
              class="outline-cover"
              @click="ImgVisible = true"
              :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
              alt=""
            />
            <videoview @click="audioplay(false)" :info="props.info"></videoview>
          </div>
        </div>
      </div>
      <div class="content-box-1" v-else>
        <p class="outline-subTitle" v-if="props.info.subTitle">
          {{ props.info.subTitle }}
        </p>
        <div class="TextMax-box" v-if="props.info.remarks">
          <TextMax
            v-if="props.domShow"
            :data="props.info.remarks"
            :title="props.info.text"
            :infoData="props.info"
            :row="4"
          ></TextMax>
        </div>

        <div
          class="content-item-1"
          :class="{ 'content-item-2': !props.info.subTitle }"
          v-if="props.info.value || (props.info.video && props.info.video.url)"
        >
          <div class="medium">
            <img
              v-if="props.info.value && !(props.info.video && props.info.video.url)"
              class="outline-cover"
              @click="ImgVisible = true"
              :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
              alt=""
            />
            <videoview @click="audioplay(false)" :info="props.info"></videoview>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free8Style2',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 220px linear-gradient(transparent, rgba(0, 0, 0, 0.2));
  margin: 0 80px;
}
.outline-parent-bg {
  width: 634px;
  height: 440px;
  margin-top: 50px;
  margin-right: 10px;
}

.outline {
  position: absolute;
  top: 50px;
  left: 0;
  z-index: 20;
  width: 634px;
  height: 440px;
  padding: 86px 58px 86px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.outline-title {
  width: 385px;
  ::v-deep p {
    width: 385px;
    font-family: 'SourceHanSerifCN-Bold';
    font-size: 20px;
    color: rgba(251, 245, 146, 1);
    line-height: 30px;
    text-align: center;
    text-shadow: 0px 3px 2px rgba(0, 0, 0, 0.5), 0px -1px 1px rgba(0, 0, 0, 0.15);
  }
  .outline-title-bg {   
    width: 385px;  
    height: 6px;
    object-fit: contain;
    margin-top: 4px;
  }
} 
 
.content-box {
  display: flex;
  width: 100%;
  margin-top: 10px;
}
.outline-content {
  width: 289px;
  display: flex;
  flex-direction: column;
  margin-right: 20px;
}

.outline-subTitle {
  width: 100%;
  font-family: SourceHanSerifCN;
  font-size: 18px;
  color: #ffffff;
  line-height: 24px;
  text-align: center;
  position: relative;
  margin-bottom: 10px;
}
.content-item {
  // width: 100%;
  height: 218px;
  flex: 1;
  flex-shrink: 0;
  background: rgba(134, 161, 146, 0.4);
}
.content-box-1 {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 393px;
  margin-top: 10px;
  .TextMax-box {
    width: 100%;
    margin-top: 10px;
  }
  .outline-subTitle{
      margin-bottom: 0px;
  }
}
.content-item-1 {
  width: 100%;
  height: 163px;
  margin-top: 10px;
  background: rgba(134, 161, 146, 0.4);
}
.content-item-2 {
  width: 100%;
  height: 223px;
  margin-top: 10px;
  background: rgba(134, 161, 146, 0.4);
}
.TextMax-box {
  width: 100%;
}
.medium {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  &:hover .outline-cover {
    transform: scale(1.2);
  }
  ::v-deep .mask-layer {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 50%;
    transform: translate(0%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    .round {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 1);
      text-align: center;
      .freeIcon {
        font-size: 24px;
        line-height: 38px;
        color: rgba(255, 255, 255, 1);
      }
    }
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    overflow: hidden;
    transition: all 0.3s ease;
  }
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
.audio-box {
  position: absolute;
  top: 48px;
  right: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e8e4d9;
  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
  border: 2px solid #345746;
  &:hover {
    background: rgba(218, 211, 190, 1);
  }
  .doorIcon {
    font-size: 24px;
    color: rgba(52, 87, 70, 1);
  }
}

::v-deep .van-text-ellipsis {
  font-family: PingFangSC !important; 
  font-size: 16px !important; 
  color: rgba(255, 255, 255, 0.8) !important;
  line-height: 32px !important; 
}
::v-deep .van-text-ellipsis__action::before {
  color: rgba(255, 255, 255, 1) !important;
  font-weight: 400 !important;
  text-decoration-line: underline;
}
</style>
